package com.bytebuffer;

import java.util.Arrays;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class UnpooledByteBufAllocatorDemo {

	public static void main(String[] args) {
		ByteBuf buf1 = Unpooled.buffer(10);
		byte[] bytes = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
		buf1.writeBytes(bytes);
        System.out.println("写入的bytes为====================>" + Arrays.toString(bytes));
        System.out.println("写入一段内容后ByteBuf为===========>" + buf1.toString());
        System.out.println("2.ByteBuf中的内容为===============>" + Arrays.toString(buf1.array()) + "\n");
        byte b1 = buf1.readByte();

        ByteBuf buf2 = Unpooled.directBuffer(10);
        buf2.writeBytes(bytes);
        buf2.writeByte(9);
        byte b2 = buf2.readByte();
        //buf2.discardReadBytes();
        //buf2.setZero(1, 5);
	}

}
